a11y: Icons in buttons are presentational
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 12 Nov 2020 14:53:16 +0000 (14:53 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Thu, 12 Nov 2020 21:46:06 +0000 (21:46 +0000)
Buttons are described by text, and the icon child can be safely ignored.

gtk/gtkbutton.c
gtk/gtkmodelbutton.c

index 059853106a535ea6d0e8f726f96757b4106ac021..9e9a15a42261f4ba022880360f49a243dd1f174b 100644 (file)
@@ -927,7 +927,10 @@ gtk_button_set_icon_name (GtkButton  *button,
 
   if (priv->child_type != ICON_CHILD || priv->child == NULL)
     {
-      GtkWidget *child = gtk_image_new_from_icon_name (icon_name);
+      GtkWidget *child = g_object_new (GTK_TYPE_IMAGE,
+                                       "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
+                                       "icon-name", icon_name,
+                                       NULL);
       gtk_button_set_child (GTK_BUTTON (button), child);
       gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
       gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button");
index c6e3d04f108f415f8b336fbdc1b30176e565829f..9efed319aa673cd0d35286d26b8531a8e4a55ab7 100644 (file)
@@ -648,7 +648,10 @@ gtk_model_button_set_icon (GtkModelButton *self,
 {
   if (!self->image && icon)
     {
-      self->image = gtk_image_new_from_gicon (icon);
+      self->image = g_object_new (GTK_TYPE_IMAGE,
+                                  "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
+                                  "gicon", icon,
+                                  NULL);
       gtk_widget_insert_before (self->image, GTK_WIDGET (self), self->label);
     }
   else if (self->image && !icon)